package com.example.demo

import org.apache.activemq.artemis.jms.client.ActiveMQQueue
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.context.annotation.Bean
import org.springframework.messaging.converter.MappingJackson2MessageConverter
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
import javax.jms.Destination

@SpringBootApplication
class DemoApplication: WebMvcConfigurer {

//	@Bean
//	@Profile("dev")
//	fun dateLoader(repo: IngredientRepository): CommandLineRunner {
//		TODO()
//	}

	@Bean
	fun orderQueue(): Destination {
		return ActiveMQQueue("localhost:8161")
	}

	@Bean
	fun messageConverter(): MappingJackson2MessageConverter {
		val converter = MappingJackson2MessageConverter().apply {
//			val typeIdMappings = hashMapOf<String, Class<*>>()
//			typeIdMappings["order"] = Order::class.java
		}
		return converter
	}

	override fun addViewControllers(registry: ViewControllerRegistry) {
		registry.addViewController("/").setViewName("home")
		registry.addViewController("/login")
	}
}

fun main(args: Array<String>) {
	runApplication<DemoApplication>(*args)
}
